<?php

namespace common\entities\myhtsq;

use Yii;

/**
 * This is the model class for table "myscrm_erp_business_unit".
 *
 * @property string $BUGUID
 * @property string $BUName
 * @property string $BUFullName
 * @property string $BUCode
 * @property string $HierarchyCode
 * @property string $ParentGUID
 * @property string $WebSite
 * @property string $Fax
 * @property string $CompanyAddr
 * @property string $Charter
 * @property string $CorporationDeputy
 * @property string $CreatedOn
 * @property string $ModifiedOn
 * @property string $CreatedBy
 * @property string $Comments
 * @property string $ModifiedBy
 * @property boolean $IsEndCompany
 * @property boolean $IsCompany
 * @property integer $Level
 * @property integer $BUType
 * @property string $ProjGUID
 * @property string $OrderCode
 * @property string $OrderHierarchyCode
 * @property string $CompanyGUID
 * @property string $NamePath
 * @property string $FyStationGUID
 * @property string $RefStationName
 * @property string $is_valid
 * @property string $Zyx
 * @property string $IsZs
 * @property integer $IsFc
 * @property string $BUPersonInCharge
 * @property string $ParentReportGUID
 * @property string $PrincipalGUID
 * @property string $MainBuGUID
 * @property integer $BusinessNum
 */
class ErpBusinessUnitEntity extends \common\entities\ConfigEntity
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'myscrm_erp_business_unit';
    }


    public static function globalTableName()
    {
        preg_match("/dbname=([^;]+)/i", self::getDb()->dsn, $matches);
        return $matches[1].'.myscrm_erp_business_unit';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['BUGUID', 'BusinessNum'], 'required'],
            [['CreatedOn', 'ModifiedOn'], 'safe'],
            [['IsEndCompany', 'IsCompany'], 'boolean'],
            [['Level', 'BUType', 'IsFc', 'BusinessNum'], 'integer'],
            [['BUGUID', 'BUName', 'BUCode', 'ParentGUID', 'WebSite', 'Charter', 'CreatedBy', 'ModifiedBy', 'ProjGUID', 'CompanyGUID', 'FyStationGUID', 'Zyx', 'BUPersonInCharge', 'ParentReportGUID', 'PrincipalGUID', 'MainBuGUID'], 'string', 'max' => 50],
            [['BUFullName', 'CompanyAddr'], 'string', 'max' => 100],
            [['HierarchyCode', 'Comments', 'OrderHierarchyCode'], 'string', 'max' => 500],
            [['Fax', 'CorporationDeputy', 'OrderCode'], 'string', 'max' => 20],
            [['NamePath', 'RefStationName'], 'string', 'max' => 1000],
            [['is_valid', 'IsZs'], 'string', 'max' => 10]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'BUGUID' => 'Buguid',
            'BUName' => 'Buname',
            'BUFullName' => 'Bufull Name',
            'BUCode' => 'Bucode',
            'HierarchyCode' => 'Hierarchy Code',
            'ParentGUID' => 'Parent Guid',
            'WebSite' => 'Web Site',
            'Fax' => 'Fax',
            'CompanyAddr' => 'Company Addr',
            'Charter' => 'Charter',
            'CorporationDeputy' => 'Corporation Deputy',
            'CreatedOn' => 'Created On',
            'ModifiedOn' => 'Modified On',
            'CreatedBy' => 'Created By',
            'Comments' => 'Comments',
            'ModifiedBy' => 'Modified By',
            'IsEndCompany' => 'Is End Company',
            'IsCompany' => 'Is Company',
            'Level' => 'Level',
            'BUType' => 'Butype',
            'ProjGUID' => 'Proj Guid',
            'OrderCode' => 'Order Code',
            'OrderHierarchyCode' => 'Order Hierarchy Code',
            'CompanyGUID' => 'Company Guid',
            'NamePath' => 'Name Path',
            'FyStationGUID' => 'Fy Station Guid',
            'RefStationName' => 'Ref Station Name',
            'is_valid' => 'Is Valid',
            'Zyx' => 'Zyx',
            'IsZs' => 'Is Zs',
            'IsFc' => 'Is Fc',
            'BUPersonInCharge' => 'Buperson In Charge',
            'ParentReportGUID' => 'Parent Report Guid',
            'PrincipalGUID' => 'Principal Guid',
            'MainBuGUID' => 'Main Bu Guid',
            'BusinessNum' => 'Business Num',
        ];
    }
}
